#ifndef LOCAL_MINIMIZATION_H_
#define LOCAL_MINIMIZATION_H_

template<typename FUNCTION>
class minimization
{
public:
	typedef FUNCTION Function;
	typedef typename Function::vector vector;

	template<typename Checker, typename Director, typename Stepper>
	static vector minimize(const Function& function, const vector& start, Checker& checker, const Director& director, const Stepper& stepper)
	{
		vector position=start;
		int iteration=0;
		while(!checker(function, position, iteration))
		{
			const vector direction=director(function, position, iteration);
			const double step=stepper(function, position, direction);
			position=position+(direction*step);
			iteration++;
		}
		return position;
	}
};

#endif /* LOCAL_MINIMIZATION_H_ */
